package inits

import (
	"fmt"
	"gateway/global/model"
	"gateway/kitex_gen/comment/commentservice"
	maps "gateway/kitex_gen/maps/locationservice"
	user "gateway/kitex_gen/user/userservice"

	"github.com/cloudwego/kitex/client"
)

func Init() {
	CommentConn()
	MapsConn()
	UserConn()
}

func UserConn() {
	var err error
	model.UserConn, err = user.NewClient("user", client.WithHostPorts("127.0.0.1:50053"))
	if err != nil {
		panic(err)
	}
	fmt.Println("user conn success")
}

func MapsConn() {
	var err error
	model.MapsConn, err = maps.NewClient("maps", client.WithHostPorts("127.0.0.1:50052"))
	if err != nil {
		panic(err)
	}
	fmt.Println("maps conn success")
}

func CommentConn() {
	var err error
	model.CommentConn, err = commentservice.NewClient("comment", client.WithHostPorts("127.0.0.1:50051"))
	if err != nil {
		panic(err)
	}
	fmt.Println("comment conn success")
}
